<template>
  <div class="data-analytics-container">
    <div class="page-header">
      <h2>数据分析</h2>
      <div class="header-actions">
        <button class="btn-primary">导出报告</button>
        <button class="btn-secondary">刷新数据</button>
      </div>
    </div>
    
    <div class="analytics-grid">
      <div class="chart-card">
        <h3>用户增长趋势</h3>
        <div class="chart-placeholder">
          <p>用户增长图表将在此处显示</p>
        </div>
      </div>
      
      <div class="chart-card">
        <h3>知识创建统计</h3>
        <div class="chart-placeholder">
          <p>知识创建图表将在此处显示</p>
        </div>
      </div>
      
      <div class="chart-card">
        <h3>问答活跃度</h3>
        <div class="chart-placeholder">
          <p>问答活跃度图表将在此处显示</p>
        </div>
      </div>
      
      <div class="chart-card">
        <h3>系统使用率</h3>
        <div class="chart-placeholder">
          <p>系统使用率图表将在此处显示</p>
        </div>
      </div>
    </div>
    
    <div class="analytics-content">
      <div class="stats-section">
        <h3>关键指标</h3>
        <div class="stats-grid">
          <div class="stat-item">
            <div class="stat-icon">👥</div>
            <div class="stat-info">
              <h4>总用户数</h4>
              <p class="stat-value">1,256</p>
              <span class="stat-change positive">+12%</span>
            </div>
          </div>
          
          <div class="stat-item">
            <div class="stat-icon">📚</div>
            <div class="stat-info">
              <h4>知识总数</h4>
              <p class="stat-value">8,945</p>
              <span class="stat-change positive">+18%</span>
            </div>
          </div>
          
          <div class="stat-item">
            <div class="stat-icon">❓</div>
            <div class="stat-info">
              <h4>问答总数</h4>
              <p class="stat-value">15,678</p>
              <span class="stat-change positive">+25%</span>
            </div>
          </div>
          
          <div class="stat-item">
            <div class="stat-icon">📈</div>
            <div class="stat-info">
              <h4>活跃度</h4>
              <p class="stat-value">89%</p>
              <span class="stat-change positive">+5%</span>
            </div>
          </div>
        </div>
      </div>
      
      <div class="reports-section">
        <h3>分析报告</h3>
        <div class="report-list">
          <div class="report-item">
            <div class="report-icon">📊</div>
            <div class="report-content">
              <h4>月度使用报告</h4>
              <p>2024年1月系统使用情况分析</p>
              <span class="report-date">2024-01-31</span>
            </div>
            <button class="btn-sm">查看</button>
          </div>
          
          <div class="report-item">
            <div class="report-icon">📈</div>
            <div class="report-content">
              <h4>用户行为分析</h4>
              <p>用户使用习惯和偏好分析</p>
              <span class="report-date">2024-01-28</span>
            </div>
            <button class="btn-sm">查看</button>
          </div>
          
          <div class="report-item">
            <div class="report-icon">📋</div>
            <div class="report-content">
              <h4>知识质量报告</h4>
              <p>知识内容质量和审核情况</p>
              <span class="report-date">2024-01-25</span>
            </div>
            <button class="btn-sm">查看</button>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
// 数据分析组件逻辑
</script>

<style scoped>
.data-analytics-container {
  padding: 0;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.page-header h2 {
  color: #1f2937;
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
}

.header-actions {
  display: flex;
  gap: 1rem;
}

.btn-primary {
  background: #4f46e5;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  cursor: pointer;
  font-weight: 500;
}

.btn-secondary {
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #d1d5db;
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  cursor: pointer;
  font-weight: 500;
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.chart-card {
  background: white;
  border-radius: 0.75rem;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.chart-card h3 {
  color: #1f2937;
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0 0 1rem 0;
}

.chart-placeholder {
  height: 200px;
  background: #f9fafb;
  border: 2px dashed #d1d5db;
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
}

.analytics-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}

.stats-section,
.reports-section {
  background: white;
  border-radius: 0.75rem;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.stats-section h3,
.reports-section h3 {
  color: #1f2937;
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0 0 1rem 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  background: #f9fafb;
  border-radius: 0.5rem;
}

.stat-icon {
  font-size: 1.5rem;
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  border-radius: 0.375rem;
}

.stat-info {
  flex: 1;
}

.stat-info h4 {
  color: #6b7280;
  font-size: 0.875rem;
  font-weight: 500;
  margin: 0 0 0.25rem 0;
}

.stat-value {
  color: #1f2937;
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 0.25rem 0;
}

.stat-change {
  font-size: 0.75rem;
  font-weight: 500;
}

.stat-change.positive {
  color: #059669;
}

.report-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.report-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: #f9fafb;
  border-radius: 0.5rem;
}

.report-icon {
  font-size: 1.5rem;
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  border-radius: 0.375rem;
}

.report-content {
  flex: 1;
}

.report-content h4 {
  color: #1f2937;
  font-size: 0.875rem;
  font-weight: 600;
  margin: 0 0 0.25rem 0;
}

.report-content p {
  color: #6b7280;
  font-size: 0.75rem;
  margin: 0 0 0.25rem 0;
}

.report-date {
  color: #9ca3af;
  font-size: 0.75rem;
}

.btn-sm {
  background: #4f46e5;
  color: white;
  border: none;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  cursor: pointer;
  font-size: 0.75rem;
}

@media (max-width: 768px) {
  .analytics-content {
    grid-template-columns: 1fr;
  }
  
  .analytics-grid {
    grid-template-columns: 1fr;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
  }
}
</style>
